<script>

import * as echarts from 'echarts';
export default {
  name: 'VisualizationTwo',
  data() {
    return{

    }
  },
  mounted() {
    this.getData();
  },
  methods:{open1(msg) {
      this.$notify({
        title: msg,
        message: '这是一条成功的提示消息',
        type: 'success'
      });
    },
    open2(msg) {
      this.$notify({
        title: msg,
        message: '这是一条警告的提示消息',
        type: 'warning'
      });
    },
    open4(msg) {
      this.$notify.error({
        title: msg,
        message: '这是一条错误的提示消息'
      });
    },
    getData(){
      this.$axios.get('/api/vis/getData3', {

      }).then(res =>{

        if (res.data.code === 20041) {
          let data1 = [];
          let data2 = [];
          for (let i = 0; i < res.data.data.length; i++) {
            data1.push(
                res.data.data[i]["param"]
            );
            data2.push(
                res.data.data[i]["param1"]
            )
          }
          this.init(data1, data2);
        }

      }).catch(error =>{
        error = "系统出错了"
        this.open4(error)
      })
    },
    init(data1, data2) {
      var chartDom = document.getElementById('main-box2');
      var myChart = echarts.init(chartDom);
      var option;

      option = {
        color: ['#f1939c'],
        title: [
          {
            text: '房租价格信息'
          }
        ],
        polar: {
          radius: [30, '80%']
        },
        radiusAxis: {
          max: 4
        },
        angleAxis: {
          type: 'category',
          data: data1,
          startAngle: 75
        },
        tooltip: {},
        series: {
          type: 'bar',
          data: data2,
          coordinateSystem: 'polar',
          label: {
            show: true,
            position: 'middle',
            formatter: '{b}: {c} 座'
          }
        },
        animation: false
      };

      option && myChart.setOption(option);

    }
  }
}

</script>

<template>
  <div id="main-box2"></div>
</template>

<style scoped>
#main-box2 {
  height: 100%;
  width: 100%;
}
</style>